import rxAjax from "@/assets/js/ajax.js";

export const FormApi = {};

FormApi.invoke= function(alias,params){
    var url="/api-form/form/core/formInvokeScript/invoke/"+alias;
    return rxAjax.postJson(url,params);
}

FormApi.queryForJson=function(sqlKey,params) {
    let url= "/api-form/form/core/formCustomQuery/queryForJson_"+sqlKey;
    return rxAjax.postForm(url,params);
}

FormApi.loadByGrant=function(typeId){
    let url = "/api-form/form/core/formEntityDataSetting/queryData_"+typeId;
    return rxAjax.get(url);
}


FormApi.loadDicByPidAndDicId=function(dicKey,parentId) {
    let url= "/api-system/system/core/sysDic/getByPidAndDicId";
    let params={dicKey:dicKey,parentId:parentId};
    return rxAjax.get(url,params);
}

/**
 * 获取当前人的所有部门数据
 * @param companyId
 * @returns {*}
 */

FormApi.getDepartments=function() {
    let url= "/api-user/user/org/osGroup/getDepartments";
    return rxAjax.get(url);
}
/**
 * 设置部门。
 * @param departmentId
 * @returns {*}
 */
FormApi.setDepartment=function(departmentId) {
    let params={departmentId:departmentId};
    let url= '/api-uaa/oauth/user/switchDepartment';
    return rxAjax.postForm(url,params);
}

/**
 * 设置用户时区。
 * @param timeZone
 * @returns {*}
 */
FormApi.setTimeZone=function(timeZone){
    var url = '/api-user/user/org/osUser/setTimeZone';
    let params={timeZone:timeZone};
    return rxAjax.postForm(url,params);
}

//获取我的消息提醒
FormApi.getMyRemind=function(){
    let url = '/api-portal/portal/core/insRemindDef/myRemind';
    return rxAjax.get(url);
}

/**
 * 获取当前公司数据
 * @returns {*}
 */
FormApi.getCompanys=function(){
    let url = '/api-user/user/org/osGroup/getCompanys';
    return rxAjax.get(url);
}

FormApi.setCompany=function(companyId) {
    let params={companyId:companyId};
    var url= '/api-uaa/oauth/user/switchCompany';
    return rxAjax.postForm(url,params);
}

export  default FormApi;
